package com.lianyanxian.countwords;
import java.util.Map;

import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.chart.*;
import org.jfree.chart.plot.PlotOrientation;
/**
 * 图表生成辅助工具
 * @author lianyanxian
 *
 */
public class JfreeChartUtil {
	
    public static void creatChart(Map<String, Integer> result){
       DefaultCategoryDataset dataset = new DefaultCategoryDataset();
       
        for(String token : result.keySet()){  
    	        Integer Num = result.get(token); 
    	        dataset.addValue(Num, token, token);
    	    }  
        
       JFreeChart chart=ChartFactory.createBarChart3D("countWords", "Words", "Number", dataset, PlotOrientation.VERTICAL, true, true, true);
       ChartFrame  frame=new ChartFrame ("countWords ",chart,true);
       frame.pack();
       frame.setVisible(true);
    }
 
}

